https://leetcode-cn.com/problems/gou-jian-cheng-ji-shu-zu-lcof/

class Solution {
public:
    vector<int> constructArr(vector<int>& a) {
        if(a.empty()) return a;
        int n = a.size();

        vector<int> v(n);
        for(int i = 0, p = 1; i < n; i++)
        { 
            v[i] = p;    //遍历原数组a计算的乘积暂存到v中
            p *= a[i];  //利用临时变量累计乘积
        }

        for(int i = n - 1, p = 1; i >= 0; i--)
        {
            v[i] *= p;  // 遍历原数组a计算的乘积暂存到v中
            p *= a[i];  //利用临时变量累计乘积
        }
        return v;
    }
};
